<template>
	<view>
		<view class="login-card body-box">
			<view class="login-label" >原密码</view>
			<input v-model="old_pwd" placeholder="请输入原密码" class="login-input" />
			<view class="login-label" >新密码</view>
			<input v-model="password" placeholder="请输入新密码" type="password" class="login-input" />
			<view class="login-label" >确认密码</view>
			<input v-model="re_password" placeholder="请输入确认密码" type="password" class="login-input" />
		</view>
		<view class="login-btn" @tap="changePwd()">立即修改</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				old_pwd:'',
				password:'',
				re_password:'',
			}
		},
		methods:{
			changePwd(){
				if(!this.old_pwd)return this.toast('请输入原密码');
				if(!this.password)return this.toast('请输入新密码');
				if(this.password != this.re_password)return this.toast('重复密码错误');
				this.ajax('home/setPwd',{
					data:{
						old_pwd : this.old_pwd,
						password : this.password,
					},
					success:(res) => {
						this.toast(res.msg);
						if(res.code){
							uni.navigateTo({
								url:'/pages/login/login'
							})
						}
					}
				})
			},
		}
	}
</script>

<style>
	@import url("@/static/css/login/login.css");
</style>
